package cc.common.manager;


import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 对外接口管理
 */
public class ApiManager implements IManager {
    /**
     * 存放api
     */
    private Map<String, Object> apiMap = new ConcurrentHashMap<>();

    private ApiManager() {
    }

    public static ApiManager getInstance() {
        return InnerClass.manager;
    }

    @Override
    public void register(Class cls, Object object) {
        apiMap.put(cls.getName(), object);
    }

    @Override
    public void unregister(Class cls) {
        apiMap.remove(cls.getName());
    }

    @Override
    public Object get(Class cls) {
        return apiMap.get(cls.getName());
    }

    private static class InnerClass {
        static ApiManager manager = new ApiManager();
    }
}
